package com.to8to.autotask.lundan;

import it.sauronsoftware.cron4j.Scheduler;

import java.util.Date;

public class TestScheduler {

	public static void main(String[] args) throws InterruptedException {
		
		// Creates a Scheduler instance.
		Scheduler s = new Scheduler();
		// Schedule a once-a-minute task.
		s.schedule("* * * * *", new Runnable() {
			public void run() {
				System.out.println("1:" + new Date());
			}
		});
		
		s.schedule("*/2 * * * *", new Runnable() {
			public void run() {
				System.out.println("2:" + new Date());
			}
		});
		
		// Starts the scheduler.
		s.start();
		// Will run for ten minutes.
		try {
			Thread.sleep(1000L * 60L * 10L);
		} catch (InterruptedException e) {
			;
		}
		// Stops the scheduler.
		s.stop();

	}

}
